<template lang="jade">

div.return-bar
	i.iconfont(@click="back()") &#xe668;
	开通华兴银行存管账户

div.openAccount.detail_top
	strong 请输入您的真实信息，否则会影响您的充值提现
		ul
			li
				label 真实姓名
				input(name="realname",value="1123", v-model="realname",placeholder="请输入持卡人真实姓名")
			li
				label 身份证号
				input(name="card",value="45050119801007047X", v-model="card",placeholder="请输入身份证号码")
		div.btn
			button.m_btn(type="button", @click="doIt()") 下一步


formpage(:url.sync="post_url", :rdata.sync="post_data")

</template>


<script>
import '../../assets/sass/user/index.scss'
import {Api_openAccount} from '../../config/api'
import FormPage from '../../components/common/form'

export default {

  data () {
    return {
      post_url: '',
      post_data:{},
      show_loading:false,
      realname: '',
      card: ''
    }
  },
  components:{
    formpage: FormPage
  },
  methods: {
    back(){
      //window.history.back();
      this.$route.router.go('/user')
    },

   doIt: function () {
      if(this.realname == '' || this.card == ''){
        alert('请填写完整的信息！')
        return false;
      }
      this.$store.dispatch('setShowLoading', true);
      var data = {'card':this.card, 'realname': this.realname}

      this.$http.post(Api_openAccount, data,'').then(function (response) {
          var rs = response.data;
          this.$store.dispatch('setShowLoading', false);
          if(!rs.status){
            alert(rs.msg)
          }else {
            console.log(this.$children.length)
            this.$children[0].show = true
            this.post_url = rs.action_url
            this.post_data.RequestData = rs.RequestData
            this.post_data.transCode = rs.transCode
            this.$children[0].submit();

          }
      }, function (response) {

      });


    }
  },
  route: {
    activate ( transition ) {
      if(sessionStorage.getItem("login")==null){
        this.$route.router.go('/login?from='+this.$route.path.substring(1))
        return false;
      }

      transition.next();
    }
  }
}
</script>
